﻿using NETCore.Encrypt;
using System;
using System.Collections.Generic;
using System.Text;

namespace TL_Cloud.Utils
{
   

    /// <summary>
    /// AES加解密
    /// 高级加密标准
    /// </summary>
    public class AESHelper
    {
        private readonly string encryptKey="";
 

        public AESHelper(string encryptKey)
        {
            if (string.IsNullOrEmpty(encryptKey))
            {
                throw new ArgumentException("message", nameof(encryptKey));
            }

            this.encryptKey = encryptKey;
        }

       
        public string Encrypt(string content,string vector="")
        {
            if (string.IsNullOrEmpty(vector))
            {
                return EncryptProvider.AESEncrypt(content, encryptKey);
            }
            else
            {
                return EncryptProvider.AESEncrypt(content, encryptKey, vector);
            }
        }

       
        public string Decrypt(string content,string vector = "")
        {
            if (string.IsNullOrEmpty(vector))
            {
                return EncryptProvider.AESDecrypt(content, encryptKey);
            }
            else
            {
                return EncryptProvider.AESDecrypt(content, encryptKey, vector);
            }
        }

    }
}
